$(function() {

		var idOS = null;
		var idDesigner = null;

		$("#tabelaOS tbody tr").draggable({
			revert : "invalid",
			revertDuration : 1000,
			helper : "clone",
			cursorAt : {
				top : 10,
				left : 10
			},
			cursor : "move",
			start : function() {
				if($(this).attr("id") == "notDrag"){
					$("body").css("cursor","default");
					return false;
				}
				idOS = $(this).attr("id");
			}
		});
		$("#fildDesigners .divScroll").droppable({

			activeClass : "ui-priority-secondary",
			hoverClass : "ui-priority-primary",
			accept : "#tabelaOS tbody tr",
//			activate: function() {
//				$("#divDesigners .divScroll table").addClass("ui-state-highlight");
//			},
//			deactivate: function() {
//				$("#divDesigners .divScroll table").removeClass("ui-state-highlight");
//			},
			over: function() {
				$(this).removeClass("ui-priority-secondary");
			},
			out: function() {
				$(this).addClass("ui-priority-secondary");
			},
			drop : function() {
				idDesigner = $(this).attr("id");	
				$.ajax({
					url:"enviaOsDesignerServlet",
					data:{idOS: idOS, idDesigner: idDesigner},
					success:function(html){
						if(html == "atualiza"){
							$('#fildDesigners').load('ajax/atualizaFieldsetDesigner.jsp');
							$("#tabelaNovaOS").load("ajax/atualizaTabelaOs.jsp");
						}else
						if(html != "naoAtualiza"){
							$("#msnConfirmaTrocaOs").html(html);
							$("#idDesignerConfirmaTrocaOs").val(idDesigner);
							$("#idConfirmaTrocaOs").val(idOS);
							$("#dialogConfirmaTrocaOs").dialog("open");
						}
					}
				});
			}
		});
	});